package com.hy.lightning.commons.utils;

import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtil {

	public static void main(String[] args) {
		String text = "\r\nContent-Disposition: form-data; name=\"uploadFile\"; filename=\"新建文本文档.txt\"\r\n"
					 +"Content-Type: text/plain\r\n";
		System.out.println(text);
		System.out.println(matcher(text, "(?<=filename=\").+?(?=\")"));
		String filename = "新建文本文档.txt";
		System.out.println(filename.substring(filename.lastIndexOf(".")));
	}

	public static String matcher(String text, String regex) {
		Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(text);
		if(matcher.find()) return matcher.group();
		return null;
	}
	
	public static String getUUID() {
		return UUID.randomUUID().toString().replace("-", "");
	}
}
